<?php

namespace app\index\controller;
use icontroller\admin\AController;
use logic\admin\index\LIndex;
use think\Config;
use think\Cookie;


class Index extends AController {

    private $logic;
    function __construct()
    {
        parent::__construct();
        $this->logic=new LIndex();
    }

    public function index() {
        $admin=$this->logic->index();
        $this->assign('admin',$admin);
        return view();
    }

    public function change_password(){
        return view();
    }

    public function change_password_save(){
        $cookie_name =  Config::get('const.cookie_name_admin');
        $id = Cookie::get($cookie_name);
        $param=array(
            'old_password'=>input('old_password'),
            'new_password'=>input('new_password'),
            'confirm_password'=>input('confirm_password'),
        );
        return $this->logic->change_password_save($id,$param);
    }


    public function home(){
        //今日增加订单数
        $today_add_order = $this->logic->today_add_order();
        $this->assign('today_add_order',$today_add_order);
        //今日新增会员数量
        $today_add_account = $this->logic->today_add_shop_user();
        $this->assign('today_add_account',$today_add_account);
        //今日新增配送员数量
        $today_add_account_deliivery = $this->logic->today_add_account_deliivery();
        $this->assign('today_add_account_deliivery',$today_add_account_deliivery);

        //会员总数
        $account_count = $this->logic->account_count();
        $this->assign('account_count',$account_count);

        //配送员总数
        $delivery_count = $this->logic->delivery_count();
        $this->assign('delivery_count',$delivery_count);

        //商品总数
        $goods_count = $this->logic->goods_count();
        $this->assign('goods_count',$goods_count);

        //订单总数
        $order_count = $this->logic->order_count();
        $this->assign('order_count',$order_count);

        return view();
    }

}
